//
//  ByLoginAndRegisterVC.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/8.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByLoginAndRegisterVC.h"
// vc
#import "ByLoginVC.h"
#import "ByRegisterVC.h"

// tabbar
#import "ByTabBarUser.h"

@interface ByLoginAndRegisterVC ()

@end

@implementation ByLoginAndRegisterVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createViews];
}

#pragma mark - create views
- (void)createViews{
    UIView *logoHeaderView = [[UIView alloc] init];
    [self.view addSubview:logoHeaderView];
    [logoHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        if (@available(iOS 11.0,*)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        }else{
            make.top.equalTo(self.view.mas_top);
        }
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT / 2 - 100));
    }];
    logoHeaderView.backgroundColor = BY_THEME_COLOR;
    
    // 注册
    UIButton *registButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:registButton];
    CGFloat width = [@"注册" getSizeOfString:15].width + 80;
    [registButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@((SCREEN_WIDTH - width) / 2));
        make.top.equalTo(logoHeaderView.mas_bottom).offset(80);
        make.size.mas_equalTo(CGSizeMake(width, 40));
    }];
    [registButton setTitle:@"注册" forState:UIControlStateNormal];
    [registButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    registButton.titleLabel.font = FONT(15);
    registButton.layer.cornerRadius = 4.0;
    registButton.backgroundColor = BY_THEME_COLOR;
    
    // 登录
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:loginButton];
    [loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(registButton.mas_left);
        make.top.equalTo(registButton.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(width, 40));
    }];
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [loginButton setTitleColor:BY_THEME_COLOR forState:UIControlStateNormal];
    loginButton.layer.borderColor = BY_THEME_COLOR.CGColor;
    loginButton.layer.borderWidth = 1;
    loginButton.layer.cornerRadius = 4.0;
    loginButton.titleLabel.font = FONT(15);
    
    // 随便逛逛
    UIButton *lookButton = [[UIButton alloc] init];
    [self.view addSubview:lookButton];
    width = [@"随便逛逛" getSizeOfString:15].width + 10;
    [lookButton mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-70);
        }else{
            make.bottom.equalTo(self.view.mas_bottom).offset(-70);
        }
        make.left.equalTo(@((SCREEN_WIDTH - width) / 2));
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    [lookButton setTitle:@"随便逛逛" forState:UIControlStateNormal];
    [lookButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    lookButton.titleLabel.font = FONT(15);
    
    [registButton addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    [loginButton addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [lookButton addTarget:self action:@selector(lookAction) forControlEvents:UIControlEventTouchUpInside];
    
    
}


#pragma mark - action
- (void)loginAction{
    ByLoginVC *vc = [[ByLoginVC alloc] init];
    vc.typeFrom = @"0";
    [self by_normalPush:vc hasNavi:YES];
}

- (void)registerAction{
    ByRegisterVC *vc = [[ByRegisterVC alloc] init];
    [self by_normalPush:vc hasNavi:YES];
}

- (void)lookAction{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    window.rootViewController = [[ByTabBarUser alloc] init];
}

@end
